package cn.easydroid.demo;

import java.io.IOException;

import cn.easydroid.android.log.XLog;
import cn.easydroid.data.DefaultApi;
import cn.easydroid.data.RemoteSource;
import cn.easydroid.event.LiveEventBus;
import cn.easydroid.retrofit.RetrofitManager;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Scheduler;
import io.reactivex.functions.Consumer;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;

/**
 * Create Date: 2019/9/6
 * Author: Yang Du
 * Description:
 */
public class HttpTest {
    public static void testHttp() {
        Retrofit retrofit = RetrofitManager.getRetrofitManager().getRetrofit(RemoteSource.getDomain());
        DefaultApi api = retrofit.create(DefaultApi.class);
//        Call<ResponseBody> responseBodyCall = api.hello();
//        responseBodyCall.enqueue(new Callback<ResponseBody>() {
//            @Override
//            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
//                try {
//                    XLog.i(RemoteSource.TAG,"response:"+ (response.body() != null ? response.body().string() : null));
//                } catch (IOException e) {
//                    XLog.w(RemoteSource.TAG,"response exception:"+e.getMessage());
//                    e.printStackTrace();
//                }
//            }
//
//            @Override
//            public void onFailure(Call<ResponseBody> call, Throwable t) {
//                XLog.i(RemoteSource.TAG,"onFailure:"+t.getMessage());
//            }
//        });
    }

    public static void testHttpRx() {
        Retrofit retrofit = RetrofitManager.getRetrofitManager().getRetrofit(RemoteSource.getDomain());
        DefaultApi api = retrofit.create(DefaultApi.class);
        Observable<ResponseBody> responseBodyObservable = api.hello();
    }
}
